import { onMounted } from 'vue'
import { addHighlight } from '@/lib/util'
// import hljs from 'highlight.js'
// import 'highlight.js/scss/github-dark.scss'

// 图片预览
export function useHighlight () {
    onMounted(async () => {
        if (!window.hljs) {
            await addHighlight()
        }
        const preCodeEls = document.querySelectorAll('pre')
        if (preCodeEls.length > 0) {
            preCodeEls.forEach(el => {
                el.innerHTML = el.innerHTML + '<a title="复制" class="iconfont copybtn" onclick="copyCode(event)">&#xe6e6;</a>'
            })
        }
        hljs.highlightAll()
    })
}
